﻿@using Kendo.Mvc.UI
<section class="container section-header">
    <div class="row">
        <div class="logo col-xs-4">
            <h1><a href="@Url.Action("Index", "Home")">TayNinhInfo.Net</a></h1>
            <hgroup class="tagline">
                <h3>Việc làm, rao vặt ở Tây Ninh</h3>
            </hgroup>
        </div>
        <!-- /.logo -->
        <div class="col-xs-8">
            <div class="advance-search">
                <div class="input-group">
                    @(Html.Kendo()
                          .DropDownList()
                          .Name("searchCatId")
                          .HtmlAttributes(new { @class = "search-box" })
                          .OptionLabel("Tất cả")
                          .DataTextField("Text")
                          .DataValueField("Key")
                          .DataSource(p => p.Read(r => r.Action("GetAllLevelCategories", "Ref")))
                          .Value((string)(ViewBag.SearchCatId ?? string.Empty)))
                    <input class="form-control" name="searchText" id="searchText" type="text" placeholder="Gõ từ khóa bạn muốn tìm kiếm..." data-val="true" data-val-required="Bạn chưa nhập từ khóa" value="@ViewBag.SearchKeyword" aria-invalid="true">
                    <div class="input-group-btn">
                        <button class="btn btn-tninfo" onclick="return searching()">
                            <i class="fa fa-search"></i> TÌM
                        </button>
                    </div>
                </div>
            </div>
            <div class="advance-create-post">
                <a href="@Url.RouteUrl("CreatePost")" class="btn btn-warning text-right">
                    <i class="fa fa-edit"></i> ĐĂNG TIN MIỄN PHÍ
                </a>
            </div>
        </div>
        
    </div>

    <script type="text/javascript">
        $('#searchText').keydown(function (e) {
            if (e.keyCode == 13) {
                searching();
            }
        });

        function searching() {
            var keyword = $('#searchText').val();
            if (keyword == "" || keyword == null)
                return;

            window.location.href = '@Url.Action("Index", "Search")' + '?c=' + $('#searchCatId').val() + '&s=' + keyword;
        }
    </script>
</section>